// pages/finsh/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    finash:[
      { img: '../../images/u213.png', name: '骆小驼', shu:'6', score: '60', img1: '../../images/icon_plus@2x.png', img2:'../../images/icon_share@2x.png',},
    ],
      quest: '排行榜',
    rank: [
      { imgs: '../../images/u213.png', names: '骆小驼', scores: '100', },
      { imgs: '../../images/u213.png', names: '骆小驼', scores: '100', },
      { imgs: '../../images/u213.png', names: '骆小驼', scores: '100', },
    ]
  },

  // 再发一个
  hair:function(){
    wx.reLaunch({
      url: '../index/index',
    })
  },

  // 炫耀一下
  show:function(){
    var that = this;
    wx.navigateTo({
      url: '../share/index?cid=' + that.data.cid + '&code_url=https://hd.huwaishequ.com/djred/public/wxcode/wx' + that.data.cid + '.png',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({ title: 'loading', mask: true })
    console.log(options.num);
    var that = this;
    that.setData({
        num: options.num, 
        cid: options.cid,
        user_img: wx.getStorageSync('avatarurl'),
        nickname: wx.getStorageSync('nickname'), 
      });
    wx.request({
      url: app.url + 'api/rank',
      data: {
        cid: options.cid,
      },
      header: { 'content-type': 'application/json' },
      success: function (res) {
        console.log(res.data);
        var data = res.data;
        that.setData({
          rank: res.data.data,
          quest:res.data.title,
        })
        wx.hideLoading();
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})